Conversation
…est the overwrite_saved_data feature
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in MultipleBuildingTypes where data keys were inconsistently mapped between reading and writing operations. The fix stores original string keys when reading data and only maps them to Resource types when calculating node usage, ensuring consistent key handling throughout the data lifecycle.
Key changes:
- Modified key mapping in
MultipleBuildingTypesto use original string keys in intermediate storage - Updated resource mapping to occur only when accumulating capacity vectors
- Changed test configuration to verify data persistence by running tests twice (once writing, once reading saved data)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/datastructures.jl | Fixed key mapping by storing original string keys and mapping to Resource types only when summing demands |
| test/utils.jl | Changed overwrite_saved_data to false to enable testing with persisted data |
| test/test_buildings.jl | Added loop to run tests twice for verifying saved data handling, plus formatting improvements |
| test/test_CSPandPV.jl | Added loop to run tests twice for verifying saved data handling, plus formatting improvements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
JulStraus
left a comment
There was a problem hiding this comment.
The changes seem reasonable to me.
I realized however a different thing which I am not entirely happy about:
We always scale in the current design from W used in the original model to MW. In practice, we should however also allow the user to specify the unit. I would hence say that we should have another PR in which we allow with a keyword argument to adjust the value, e.g.,
function MultipleBuildingTypes(
id::Any,
process_pay_load::Dict,
time_start::DateTime,
time_end::DateTime,
buildings::Vector{String},
resources_map::Dict{String,<:Resource},
T::TimeStructure,
penalty_surplus::Dict{<:Resource,<:TimeProfile},
penalty_deficit::Dict{<:Resource,<:TimeProfile};
data::Vector{<:Data} = Data[],
data_location::String = joinpath(tempdir(), "buildings"),
overwrite_saved_data::Bool = false,
unit::String = "MW",
)and in the code than an if-loop to check for the unit. Required units are probably W, kW, MW, and GW with MW being the default value.
If we explain it in the docstring and include an exception handling, it should be not an issue. I am a bit uncertain what type of error it is, but I would tend to DomainError or ArgumentError. You can also check the Julia documentation for it .
|
Thinking about it, you can also call |
There was a bug when writing data to file in MultipleBuildingTypes as the read keys are not mapped to the
Resource-type. In this PR, this is resolved by storing the original keys (which is inStringformat anyways), and handling the mapping on node usage.